package com.neutech.maplestory.client;
import com.neutech.maplestory.entity.Arrow;
import com.neutech.maplestory.entity.Hero;
import com.neutech.maplestory.util.MapleStoryFrame;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.List;

/**
 * 游戏的主入口文件
 */
public class MapleStoryClient extends MapleStoryFrame {
    public Hero hero=new Hero(this,300,500);
    public List<Arrow> arrows = new ArrayList<>();
    @Override
    public void init() {
        super.init();
        //添加键盘监听器
        this.addKeyListener(new KeyAdapter() {
            @Override
            public void keyPressed(KeyEvent e) {
                hero.keyPressed(e);

            }
            @Override
            public void keyReleased(KeyEvent e) {
                   hero.keyReleased(e);
            }
        });
    }
    @Override
    public void paint(Graphics g) {
        hero.draw(g);
        for (int i = 0 ; i < arrows.size(); i++){
            arrows.get(i).draw(g);
        }
        Font f = g.getFont();
        g.setFont(new Font("微软雅黑",Font.BOLD,30));
        g.drawString("当前人物的方向为："+hero.dir,100,100);
        g.drawString("当前人物的动作为："+hero.action,100,150);
        g.drawString("arrows.size："+arrows.size(),100,250);
        g.setFont(f);

    }

    public static void main(String[] args) {
        new MapleStoryClient().init();
    }
}
